package com.qing.seckill.controller;


import com.qing.seckill.entity.TbSeckillGoods;
import com.qing.seckill.service.ITbSeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhipeng.cao
 * @since 2021-04-19
 */
@RestController
@RequestMapping("/goods")
public class TbSeckillGoodsController {


	@Autowired
	private ITbSeckillGoodsService tbSeckillGoodsService;

	@RequestMapping("/index")
	public ModelAndView findAll(ModelAndView modelAndView) {
		modelAndView.setViewName("index");
		modelAndView.addObject("goods", tbSeckillGoodsService.list());
		return modelAndView;
	}


	@RequestMapping("/deatil/{id}")
	public ModelAndView findOne(@PathVariable("id") Long id, ModelAndView modelAndView) {
		modelAndView.setViewName("deatil");
		modelAndView.addObject("good", tbSeckillGoodsService.detail(id));
		return modelAndView;
	}

}
